import Exceptions.BootstrapException;
import Service.MiniApplicationContext;
import Service.ScanXml;
import com.whu.edu.beans.Home;
import org.junit.Assert;
import org.junit.Test;

public class testApplication {
    //正常测试
    @Test
    public void test1()
    {
        var ctx = new MiniApplicationContext("src/test/resources/test1.xml");
        Home h1 = (Home)ctx.mp.get("home1");
        Assert.assertEquals("whu",h1.getName());
    }
    //xml成员变量缺失
    @Test
    public void test2()
    {
        try
        {
            var lis = ScanXml.getAllBeanDefinition("src/test/resources/without-parameter.xml");
        }
        catch (BootstrapException e)
        {
            Assert.assertEquals(BootstrapException.ErrorType.FILE_WRITE_ERROR,e.getErrorType());
        }
    }
    //xml文件内容缺失
    @Test
    public void test3()
    {
        try
        {
            var lis = ScanXml.getAllBeanDefinition("src/test/resources/without-beans.xml");
        }
        catch (BootstrapException e)
        {
            Assert.assertEquals(BootstrapException.ErrorType.PROP_READ_ERROR,e.getErrorType());
        }
    }



}
